package com.oa.system.controller;

import com.joneying.common.web.response.Resp;
import com.oa.system.entity.DefaultSetting;
import com.oa.system.service.IDefaultSettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Description;
import org.springframework.web.bind.annotation.*;

@Api(description = "默认设置接口")
@RequestMapping("/setting")
@RestController
public class DefaultSettingController {

    @Autowired
    private IDefaultSettingService defaultSettingService;

    @Description("根据ID查询")
    @ApiOperation(value = "根据ID查询")
    @GetMapping("/{id}")
    public Resp<DefaultSetting> getById(@PathVariable String id){
        DefaultSetting defaultSetting = defaultSettingService.selectById(id);
        return new Resp().success(defaultSetting);
    }

    @Description("修改")
    @ApiOperation(value = "修改")
    @PutMapping("")
    public Resp put(DefaultSetting defaultSetting){
        if(defaultSettingService.updateById(defaultSetting)){
            return new Resp().success(defaultSetting);
        }
        return new Resp().failure();
    }
}
